package com.zhouwei.mzbanner.transformer;

import android.support.v4.view.ViewPager;
import android.view.View;

/**
 * Created by zhouwei on 17/8/20.
 */

public class CoverModeTransformer implements ViewPager.PageTransformer {

    private float reduceX = 0.0f;
    private float itemWidth = 0;
    private float offsetPosition = 0f;
    private int mCoverWidth;
    private float mScaleMax = 1.0f;
    private float mScaleMin = 0.9f;
    private ViewPager mViewPager;

    public CoverModeTransformer(ViewPager pager){
        mViewPager = pager;
    }

    @Override
    public void transformPage(View page, float position) {
        float pageWidth = page.getWidth();
        float v = Math.abs(position);
        float v1 = 0.2f * (v * v);
        //TODO 设置不透明度
        page.setAlpha(1f);
        //TODO 设置覆盖
        if (position > 1) {
            page.setScaleX(0.8f);
            page.setScaleY(0.8f);
            page.setTranslationX(-v / 2 * pageWidth);
        } else if (position >= 0) {
            page.setScaleX(1 - v1);
            page.setScaleY(1 - v1);
            page.setTranslationX(-v / 2 * pageWidth);
        } else if (position >= -1) {
            page.setScaleX(1 - v1);
            page.setScaleY(1 - v1);
            page.setTranslationX(v / 2 * pageWidth);
        } else {
            page.setScaleX(0.8f);
            page.setScaleY(0.8f);
            page.setTranslationX(v / 2 * pageWidth);
        }
    }
}

